#include <cstdint>
#include <iostream>
#include <math.h>
using namespace std;

bool Yes(int n)
{
    if (n == 1)
    {
        return true;
    }
    int k = sqrt(n);
    if (n % 2 == 0)
    {
        return false;
    }
    for (int i = 3; i <= k; i += 2)
    {
        if (n % i == 0)
        {
            return false;
        }
    }
    return true;
}

void left_right(int& left, int& right, int& my_min, int& num, int& i)
{
    if (my_min > abs((num - i) - i))
    {
        left = min(num - i, i);
        right = max(num - i, i);
        my_min = abs(num - i - i);
    }
}

int main() {
    int num;
    cin >> num;
    int my_min = INT32_MAX;
    int i = 2;
    int left = 0;
    int right = 0;
    if (Yes(num - i))
    {
        left_right(left, right, my_min, num, i);
    }
    for (i = 1; i < num; i += 2)
    {
        if (Yes(i))
        {
            if (Yes(num - i))
            {
                left_right(left, right, my_min, num, i);
            }
        }
    }
    cout << left << endl << right << endl;
    return 0;
}

class BinInsert {
public:
    int binInsert(int n, int m, int j, int i) {
        // write code here
        m <<= j;
        n |= m;
        return n;
    }
};